using AutoBackupSql;
using AutoBackupSql.Models;
using AutoBackupSql.Services;
using Quartz;

var builder = Host.CreateApplicationBuilder(args);

// 配置备份设置
builder.Services.Configure<BackupSettings>(
    builder.Configuration.GetSection("BackupSettings"));

// 注册服务
builder.Services.AddScoped<MySqlBackupService>();
builder.Services.AddScoped<FileTransferService>();

// 配置Quartz调度器
builder.Services.AddQuartz(q =>
{
    // 配置作业存储
    q.UseSimpleTypeLoader();
    q.UseInMemoryStore();
});

// 添加Quartz托管服务
builder.Services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);

// 注册Worker服务
builder.Services.AddHostedService<Worker>();

var host = builder.Build();
host.Run();
